package com.shawn.spring.boot.flowable;

import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class FlowableApplication implements ApplicationRunner {

  @Autowired private RepositoryService repositoryService;
  @Autowired private RuntimeService runtimeService;
  @Autowired private TaskService taskService;

  public static void main(String[] args) {
    SpringApplication.run(FlowableApplication.class);
  }

  @Override
  public void run(ApplicationArguments args) throws Exception {
    System.out.println(
        "Number of process definitions : "
            + repositoryService.createProcessDefinitionQuery().count());
    System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
    //    runtimeService.startProcessInstanceByKey("oneTaskProcess");
    System.out.println("hello world");
  }
}
